from rest_framework.serializers import ModelSerializer,SerializerMethodField
from .models import *

class DianjiaSer(ModelSerializer):
    class Meta:
        model = Dianjia
        fields = '__all__'
class ShangpingSer(ModelSerializer):
    cate_name = SerializerMethodField(read_only=True)
    def get_cate_name(self,obj):
        return obj.cate.name
    class Meta:
        model = Shangping
        foelds = '__all__'

